<?php

// +----------------------------------------------------------------------
// | quickadmin框架 [ quickadmin框架 ]
// +----------------------------------------------------------------------
// | 版权所有 2020~2022 南京新思汇网络科技有限公司
// +----------------------------------------------------------------------
// | 官方网站: https://www.quickadmin.icu
// +----------------------------------------------------------------------
// | Author: zs <909883663@qq.com>
// +----------------------------------------------------------------------

namespace app\admin\controller;

use app\admin\service\MenuService;
use app\common\controller\AdminBase;
use app\common\controller\PCBase;
use app\common\controller\DBase;
use think\facade\Log;
use util\Upload;

class Ajax extends DBase
{


    /**
     * 获取网站配置项
     */
    public function getConfig()
    {
        return $this->jsonMessage(200, true, '获取成功!',  sysconfig('site'));
    }
    /**
     * 上传文件
     */
    public function upload()
    {

        $file = $this->request->file('file');
        try {
            $upload = new Upload();
            $res = $upload->upload($file);
            if ($res['url']) {
                return $this->jsonMessage(200, true, '获取成功!',  ['url' => $res['url']]);
            } else {
                return $this->jsonMessage(201, false, '获取失败!', null);
            }
        } catch (\Exception $e) {
            Log::error("---ajax---upload--error:" . $e);
        }
        return $this->jsonMessage(201, false, '上传文件失败!', null);
    }

    /**
     * 获取验证码
     */

    public function getCaptcha()
    {
        return captchaimg();
    }

}
